class Solution {
    public int[] exchange(int[] nums) {
        if(nums.length == 0) {
            return nums;
        }
        int left = 0;
        int rigth = nums.length - 1;
        while(left < rigth){
            if(nums[left]%2 == 1) {
                left++;
            }
            if(nums[rigth]%2 == 0) {
                rigth--;
            }
            if(left < rigth) {
                int tmp = nums[left];
                nums[left] = nums[rigth];
                nums[rigth] = tmp; 
            }
        }
        return nums;
    }
}